<template>
    <div>
        <h1>用户页面</h1>
         <table class="table">
            <tbody>
                <tr>
                    <th>编号</th>
                    <th>用户名称</th>
                    <th>操作</th>
                </tr>
                <tr v-for="info in item" :key="info.id">
                    <td>{{info.id}}</td>
                    <td>{{info.name}}</td>
                    <td><input type="button" value="删除" @click="del(info.cardid)"></td>
                </tr>
            </tbody>
        </table>
    </div>
</template>

<script setup lang="ts">
import axios from 'axios';
import { ref,onMounted,reactive } from 'vue';
import { useRoute,useRouter } from 'vue-router';
onMounted(()=>{
  show();  
})
const router =useRouter();
let item:any=ref([])
const show=()=>{
    axios.get('https://localhost:7145/api/Emp/GetAll',item.value).then(res=>{
        item.value=res.data;
    })
}
const del=(cardid:any)=>{
    let f = confirm('确认删除吗?')
    if(f)
    {
        axios.delete('https://localhost:7145/api/Emp/DeleteCard',{params:cardid}).then(res=>{
            if(res.data==1)
        {
            alert('删除成功');
        }
        else
        {
            alert('删除失败');
        }
            })
    }
  
}
</script>

<style scoped>

</style>